{% extends "base.html" %}
{% load djblets_deco %}
{% load i18n %}
{% block title %}{% trans "New Review Request" %}{% endblock %}

{% block css %}
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}rb/css/diffviewer.css?{{MEDIA_SERIAL}}" />
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}rb/css/reviews.css?{{MEDIA_SERIAL}}" />
{% endblock %}

{% block scripts %}
<script type="text/javascript" src="{{MEDIA_URL}}djblets/js/jquery-1.3.2.min.js"></script>
{% endblock %}

{% block scripts-post %}
<script type="text/javascript">
    var visible = {{fields|safe}};

    function updateFormDisplay() {
        var selection = $("#id_repository").get(0);
        var selectedID = selection.options[selection.selectedIndex].value;

        $("tr[id^=row_]").hide();
        $(visible[selectedID]).each(function() {
            $("tr#row_" + this).show();
        });
    }

    $(document).ready(function() {
        $("#id_repository")
            .change(updateFormDisplay)
            .triggerHandler("change");
    });
</script>
{% endblock %}

{% block content %}
<form method="post" action="." enctype="multipart/form-data">
{% box "new-review-request" %}
 <h1 class="title">{% trans "New Review Request" %}</h1>
 <div class="main">
  <table>
   <tr>
    <td><label for="id_repository">{% trans "Repository" %}:</label></td>
    {% spaceless %}<td>
     <select name="repository" id="id_repository">
      {% for repository in form.fields.repository.choices %}
       {% ifequal form.data.repository repository.0 %}
        <option value="{{repository.0}}" selected="selected">{{repository.1}}</option>
       {% else %}
        <option value="{{repository.0}}">{{repository.1}}</option>
       {% endifequal %}
      {% endfor %}
     </select>
    </td>{% endspaceless %}
   </tr>
   <tr id="row_changenum">
    <td><label for="id_changenum">{{form.changenum.label}}:</label></td>
    <td>{{form.changenum}}</td>
    <td>{{form.changenum.errors}}</td>
   </tr>
   <tr id="row_basedir">
    <td><label for="id_basedir">{{form.basedir.label}}:</label></td>
    <td>{{form.basedir}}</td>
    <td>{{form.basedir.errors}}</td>
   </tr>
   <tr id="row_diff_path">
    <td><label for="id_diff_path">{{form.diff_path.label}}:</label></td>
    <td>{{form.diff_path}}</td>
    <td>{{form.diff_path.errors}}</td>
   </tr>
  </table>
 </div>
{% endbox %}
 <div class="prefsbuttons">
  <input type="submit" value="{% trans "Create Review Request" %}" />
 </div>
</form>

{% endblock %}

